<?php
// set constant for document root path
//
if( true !== defined( 'DOCROOT' ) )
{
    if( false !== getenv( 'DOCROOT' ) )
    {
        $value = getenv( 'DOCROOT' );
    }
    else
    {
        $value = realpath( dirname( __FILE__ ) . '/../' );
    }
    define( 'DOCROOT', $value );
}

// set constant for application scripts base path
//
if( true !== defined( 'APPPATH' ) )
{
    if( false !== getenv( 'APPPATH' ) )
    {
        $value = getenv( 'APPPATH' );
    }
    else
    {
        $value = dirname( __FILE__ );
    }
    define( 'APPPATH', $value );
}

// set constant for config file path
//
if( true !== defined( 'CONF_FILE' ) )
{
    if( false !== getenv( 'CONF_FILE' ) )
    {
        $value = getenv( 'CONF_FILE' );
    }
    else
    {
        $value = APPPATH . '/etc/config.ini';
    }
    define( 'CONF_FILE', $value );
}

// set include path
//
$_org = explode( PATH_SEPARATOR, get_include_path() );
$_add = array(
             '.',
             APPPATH . '/classes',
             APPPATH . '/functions',
             APPPATH . '/vendors',
             APPPATH . '/vendors/pear',
             APPPATH . '/vendors/plugins/',
             APPPATH . '/vendors/plugins/common',
             );
$_new = array_unique( array_merge( $_add, $_org ) );
set_include_path( implode( PATH_SEPARATOR, $_new ) );
